import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;


public class WriteToFile {

	private FileWriter fw;
	static String fileName="names.txt";
	static Boolean flag=false;
	BufferedWriter out;
	public WriteToFile() throws IOException
	{
		fw=new FileWriter(fileName,flag);
		out=new BufferedWriter(fw);
	}
	public void fileAppend(ArrayList<String> names,ArrayList<String> genre,ArrayList<String> country) throws IOException
	{
		
		Iterator<String > it=names.iterator();
		
		Iterator<String > it1=genre.iterator();
		Iterator<String > it2=country.iterator();
		
		while(it.hasNext()&&it1.hasNext()&&it2.hasNext())
		{
			out.write(it.next()+","+it1.next()+","+it2.next());
			out.newLine();
		}
		out.close();
		
	}
	
}
